package com.kitty.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class LoginInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5565926901804673977L;

	@Override
	public String intercept(ActionInvocation arg0) throws Exception {
		 
		System.out.println("before ...");
		Object object = arg0.getAction();
		if (object instanceof LoginAction) {
			HttpServletRequest request = ServletActionContext.getRequest();
			String name = request.getParameter("name");
			if (!"kitty".equals(name)) {
				return "bb";
			}
		
		}
		String result = arg0.invoke();
		System.out.println("after ...");
		return result;
	}

	

}

//拦截器(interceptor),过滤器(filter),回调接口(callback),通知接口(advice),
//转发,委托,回调,
